<?php

namespace App\Http\Requests\Api;

use Illuminate\Foundation\Http\FormRequest;

class WechatRegisterRequest extends FormRequest
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        return [
            'access_token' => 'required|string',
            'openID' => 'required|string',
            'unionID' => 'required|string',
            'phone' => 'required|regex:/^1[34578][0-9]{9}$/',
            'sms_code' => 'required',
            'unionID' => 'required',
            'captcha' => 'required|captcha_api:' . request('key'),

        ];
    }

    public function messages()
    {
        return [
            'phone.required' => '手机号必须',
            'phone.regex' => '手机号格式不正确',
            'captcha.required' => '请输入图片验证码',
            'captcha.captcha_api' => '图片验证码错误',
        ];
    }

}
